local hx__pojun = fk.CreateSkill {
  name = "hx__pojun",
}

hx__pojun:addEffect(fk.TargetSpecified, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(hx__pojun.name) and data.card.trueName == "slash" and
      not data.to.dead and data.to.hp > 0 and not data.to:isNude()
  end,
  on_cost = function(self, event, target, player, data)
    if player.room:askToSkillInvoke(player, {
      skill_name = hx__pojun.name,
      prompt = "#hx__pojun-invoke::" .. data.to.id .. ":" .. data.to.hp,
    }) then
      event:setCostData(self, {tos = {data.to}})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = room:askToChooseCards(player, {
      target = data.to,
      flag = "he",
      skill_name = hx__pojun.name,
      min = 1,
      max = data.to.hp
    })
    data.to:addToPile("$hx__pojun", cards, false, self.name, player)
  end,
})

hx__pojun:addEffect(fk.DamageCaused, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return data.from == player and player:hasSkill(hx__pojun.name) and data.card and data.card.trueName == "slash" and
      data.by_user and
      player:getHandcardNum() >= data.to:getHandcardNum() and
      #player:getCardIds(Player.Equip) >= #data.to:getCardIds(Player.Equip)
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    data:changeDamage(1)
  end,
})
hx__pojun:addEffect(fk.TurnEnd, {
  is_delay_effect = true,
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return not player.dead and #player:getPile("$hx__pojun") > 0
  end,
  on_use = function(self, event, target, player, data)
    player.room:moveCardTo(player:getPile("$hx__pojun"), Player.Hand, player, fk.ReasonPrey, hx__pojun.name)
  end,
})

return hx__pojun